package de.baumann.browser.adapter

import android.view.View
import android.widget.Button
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import de.baumann.browser.OdinGlideModule
import de.baumann.browser.R
import de.baumann.browser.activitys.duobao.WuLiuActivity
import de.baumann.browser.api.net.vo.duobao.DuoBao

class DuoBaoJiangPinAdapter : BaseQuickAdapter<DuoBao, BaseViewHolder>(R.layout.item_duobao_jiangpin) {
    override fun convert(helper: BaseViewHolder, item: DuoBao) {
        helper.setText(R.id.jiangPinCode, "${item.phaseNum}期")
        helper.setText(R.id.jiangPinName, item.title)
        helper.setText(R.id.jiangPinTime, "开奖时间:${item.announceTime}")
        helper.setText(R.id.jiangPinPrice, "价值:${item.totalValue}ODIN")

        val jiangPinCover:ImageView = helper.getView(R.id.jiangPinCover)
        OdinGlideModule.load(mContext,item.thumbnail,jiangPinCover,R.drawable.shape_cover)

        val btnWuLiu:Button = helper.getView(R.id.btnWuLiu)
        btnWuLiu.setOnClickListener {
            WuLiuActivity.startWuLiuActivity(mContext,item.activityId,item.title)
        }

        when (item.shipmentsStatus) {
            0,1 -> {
                helper.setText(R.id.fhzt, "待发货")
                btnWuLiu.visibility = View.INVISIBLE
                helper.setTextColor(R.id.fhzt, mContext.resources.getColor(R.color.color_DF2627))
            }

            2 -> {
                helper.setText(R.id.fhzt, "已发货")
                btnWuLiu.visibility = View.VISIBLE
                helper.setTextColor(R.id.fhzt, mContext.resources.getColor(R.color.color_999999))
            }
        }
    }
}